home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7647 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Type casting
  5. Date: Tue, 27 Feb 96 22:35:16 GMT
  6. Organization: none
  7. Message-ID: <825460516snz@genesis.demon.co.uk>
  8. References: <4gfnmi$gsc@calvin.risq.qc.ca> <4gim30INNo4b@keats.ugrad.cs.ubc.ca> <4gkki1$a7c@charm.il.ft.hse.nl>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4gkki1$a7c@charm.il.ft.hse.nl> robert@il.ft.hse.nl "robert" writes:
  15.  
  16. >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku):
  17. > >In article <4gfnmi$gsc@calvin.risq.qc.ca>,
  18. > >Pierre Coulombe <pcoulomb@criq.qc.ca> wrote:
  19. > >>  char string[80];
  20. > >>  strcpy(string, "25.4");
  21. > >Try char *string = "25.4". This is a waste.
  22. > >>  sprintf(string, "%f", (float) atof(string) * MM_TO_UNITS);
  23. >             ^^^^^^ 
  24. >It's not a waste, you can't be certain the result will fit in the 4
  25. >chars.
  26.  
  27. It also tries to write to a string literal which is illegal.
  28.  
  29. -- 
  30. -----------------------------------------
  31. Lawrence Kirby | fred@genesis.demon.co.uk
  32. Wilts, England | 70734.126@compuserve.com
  33. -----------------------------------------
  34.